#include "ArcDialog.h"

namespace FinalRendering
{
	namespace Editor
	{
		using namespace GxRendering::UI;

		ArcCreationDialog::ArcCreationDialog()
		{
			SetClientWidth(250);
			SetClientHeight(180);
			SetText(L"Create Arc");
			SetMinimizeBox(false);
			SetMaximizeBox(false);
			SetBorder(GxWinGUI::fbFixedDialog);

			
			txtThickness = new TextBox();
			txtDegree = new TextBox();

			txtThickness->SetText(L"16");
			txtDegree->SetText(L"180");

			ui->AddChild(txtThickness);
			ui->AddChild(txtDegree);

			Label * lbl = new Label();
			lbl->SetText(L"Thickness:");
			lbl->Posit(20,20,70, 20);
			ui->AddChild(lbl);

			lbl = new Label();
			lbl->SetText(L"Angles:");
			lbl->Posit(20, 50, 70, 20);
			ui->AddChild(lbl);

			txtDegree->Posit(90, 46, 120, 20);
			txtThickness->Posit(90, 16, 120, 20);

			lbl = new Label();
			lbl->SetText(L"Segments:");
			lbl->Posit(20, 80, 70, 20);
			ui->AddChild(lbl);

			txtSegments = new TextBox();
			txtSegments->SetText(L"16");
			txtSegments->Posit(90, 76, 120, 20);
			ui->AddChild(txtSegments);

			lbl = new Label();
			lbl->SetText(L"Y Step:");
			lbl->Posit(20, 110, 70, 20);
			ui->AddChild(lbl);

			txtSegInc = new TextBox();
			txtSegInc->SetText(L"16");
			txtSegInc->Posit(90, 106, 120, 20);
			ui->AddChild(txtSegInc);

			Button * btn = new Button();
			btn->SetText(L"&OK");
			btn->Posit(50, 140, 80, 28);
			btn->OnClick.Bind(this, &ArcCreationDialog::btnOK_Clicked);
			ui->AddChild(btn);
			
			btn = new Button();
			btn->SetText(L"&Cancel");
			btn->Posit(140, 140, 80, 28);
			btn->OnClick.Bind(this, &ArcCreationDialog::btnCancel_Clicked);
			ui->AddChild(btn);

			UpDown * ud = new UpDown(txtThickness, 1.0f, 1024.0f, 1.0f, 64.0f);
			ud->Digits = 1;
			ui->AddChild(ud);

			ud = new UpDown(txtDegree, 0.0f, 360.0f, 1.0f, 90.0f);
			ud->Digits = 1;
			ui->AddChild(ud);
		}

		void ArcCreationDialog::btnOK_Clicked(UI_Base * sender)
		{
			SetDialogResult(BaseForm::OK);
		}

		void ArcCreationDialog::btnCancel_Clicked(UI_Base * sender)
		{
			SetDialogResult(BaseForm::Cancel);
		}
	}
}